#!/bin/bash 

source ./test.cfg

DEBUG=0

if [ -z $1 ]; then
  NODE=msserver01a
  ID=a11
  TOPIC=\$SharedSubscription/dog//APP/a11/#
else
  NODE=${APPLIANCE[$1]}
  ID=${APPSUB[$1]}
  TOPIC=${SHARED}/APP/${ID}/#
fi


ENDPOINT=`/niagara/test/scripts/getclusterserverendpointport.py -c ${CLUSTER} -e SVT-IntranetEndpoint -a ${NODE}`

if [ "${ORDER}" == "true" ]; then
  O=-O
else
  O=
fi

if [ ${DEBUG} -ne 0 ]; then
  echo CLUSTER=${CLUSTER}
  echo NODE=${NODE}
  echo ENDPOINT=${ENDPOINT}
  echo QOS=${QOS}
  echo MESSAGES=${MESSAGES}
fi


echo java svt.mqtt.mq.MqttSample -mqtt 3.1.1 -i ${ID} -a subscribe -t ${TOPIC} -s tcp://${ENDPOINT} -n $((${CARS}*6*${MESSAGES})) ${O} -v -e true -q ${QOS}
java svt.mqtt.mq.MqttSample -mqtt 3.1.1 -i ${ID} -a subscribe -t ${TOPIC} -s tcp://${ENDPOINT} -n $((${CARS}*6*${MESSAGES})) ${O} -v -e true -q ${QOS}



